/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.boxin.ims.modules.wechat.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;

import com.thinkgem.jeesite.common.persistence.BaseDao;
import com.thinkgem.jeesite.common.persistence.BaseDaoImpl;
import com.boxin.ims.modules.wechat.entity.LotteryRecord;
import com.boxin.ims.modules.wechat.entity.SeckillGainer;

/**
 * 中奖人记录DAO接口
 * @author Jakemanse
 * @version 2013-09-23
 */
public interface LotteryRecordDao extends LotteryRecordDaoCustom, CrudRepository<LotteryRecord, Long> {

	@Modifying
	@Query("update LotteryRecord set delFlag='" + LotteryRecord.DEL_FLAG_DELETE + "' where id = ?1")
	public int deleteById(Long id);
	
	@Modifying
	@Query("update LotteryRecord set delFlag='" + LotteryRecord.DEL_FLAG_NORMAL + "',status = ?2 ,updateTime = now()  where id = ?1")
	public int updateStatusById(Long id,String status);
	
	
	@Modifying
	@Query("update LotteryRecord t set t.delFlag='" + LotteryRecord.DEL_FLAG_NORMAL + "', t.remarks= ?3, t.status = 1 ,t.updateTime = now()  where t.user.id = ?1 and t.member.id=?2 and t.sourceType=3 and t.status=0")
	public int updateRegLotteryStatus(Long userId,Long memberId,String remarks);
	
	@Query("from LotteryRecord t where t.user.id = ?1 and t.member.id=?2 and t.sourceType=3 ")
	public LotteryRecord getRegLotteryByUserIdMemberId(Long userId,Long memberId);
	
	
	
}

/**
 * DAO自定义接口
 * @author Jakemanse
 */
interface LotteryRecordDaoCustom extends BaseDao<LotteryRecord> {

}

/**
 * DAO自定义接口实现
 * @author Jakemanse
 */
@Component
class LotteryRecordDaoImpl extends BaseDaoImpl<LotteryRecord> implements LotteryRecordDaoCustom {

}
